package website

import (
	"net/http"
	"runtime/pprof"
)

func PprofHandler(w http.ResponseWriter, r *http.Request, ctx *Context) {
	user, pwd, ok := r.BasicAuth()
	if ok {
		if "admin" == user && "password" == pwd {
			ctx.SetContentType("text/plain")
			// p := pprof.Lookup("goroutine")
			p := pprof.Lookup("heap")
			p.WriteTo(w, 1)
			return
		}
	}
	ctx.BasicAuth("Please enter the password authentication information")
}
